home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
et
/
et3_0-a1.lha
/
et3
/
src
/
StreamConnection.h
< prev
next >
Wrap
C/C++ Source or Header
|
1992-08-10
|
2KB
|
92 lines
#ifndef StreamConnection_First
#ifdef __GNUG__
//pragma once
#pragma interface
#endif
#define StreamConnection_First
#include "System.h"
#include "Data.h"
#define SERVERNAME "ET++clipboard"
#define SERVICENAME "et++clipboard"
extern bool gIACDebug;
class MemBuf;
class SeqCollection;
class StreamConnection;
//---- Message -----------------------------------------------------------------
struct block {
int len, pos;
char *buf;
block();
~block();
};
class Message : public Object {
public:
int from, to, serial;
block data[2];
public:
Message();
Message(int to, int from, int reply, char *buf, int l= -1, bool makecopy= TRUE);
int Read(int fd);
int Write(int fd);
void Print(char *from, char *to);
bool IsReply()
{ return serial < 0; }
};
//---- StreamConnection --------------------------------------------------------
class StreamConnection : public SysEvtHandler {
protected:
Message *rm;
SeqCollection *wqueue;
OrdCollection *queue;
bool error;
int serial, sid;
char *name;
bool Open(int fd);
public:
int IntSendTo(int to, int reply, char *req, char *buf, int l);
int SendTo(int to, char *req, char *buf= 0, int l= -1);
public:
MetaDef(StreamConnection);
StreamConnection(int);
~StreamConnection();
void SetName(char*);
void SendMessage(Message *m);
Message *WaitForReply(int seq, int timeout);
int DrainOutput(int timeout);
int WaitForMessage(int timeout);
void Dispatch0(Message *m);
bool Reconnect();
// obsolete interface
int Talk(int client, char *req, char *buf= 0, int len= -1,
char **retbuf= 0, int *retlen= 0);
void Talk(char *prog, char *va_(fmt), ...);
virtual void Dispatch(int from, char *req, char *buf, int len,
char *&retbuf, int &retlen);
virtual bool Dispatch2(char *req, char *buf, int len,
char *&retbuf, int &retlen, Message *m);
int Error(int code);
protected:
bool HasInterest(SysEventCodes code);
void Notify(SysEventCodes, int);
};
#endif